package org.coopac.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import org.coopac.dao.ITipoMaestroDAO;
import org.coopac.model.CoopacTipoMaestro;
import org.coopac.service.ITipoMaestroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@Service("tipoMaestroService")
public class TipoMaestroService implements ITipoMaestroService {

	@Autowired
	private ITipoMaestroDAO tipoMaestroDAO;	
	

	@Override
	public List<CoopacTipoMaestro> listarByName(String name) {
		return  tipoMaestroDAO.listarByName(name);
	}


	@Override
	public List<SelectItem> listaMaestro(String name) {
		List<CoopacTipoMaestro>  o = new ArrayList<CoopacTipoMaestro>();
		o.addAll(tipoMaestroDAO.listarByName(name));
		List<SelectItem> list = new ArrayList<SelectItem>();
		for(CoopacTipoMaestro ob : o){
			list.add(new SelectItem(ob.getIdTipoMaestro(), ob.getNombre()));
		}
		return list;
	}
	@Override
	public CoopacTipoMaestro getById(int id){
		return tipoMaestroDAO.getById(id);
	}
}
